<template>
  <div>
    <el-row :gutter="20">
      <el-col :md="5" v-for="(item, index) in pannel_data" :key="item.titl">
        <pannel :serchObj="item"> </pannel>
      </el-col>
    </el-row>

    <el-row>
      <el-col>
        <comeacharts
          :sendStyle="{ w: '100%', h: '500px', bgc: 'white' }"
          :sendOption="nav"
        >
        </comeacharts>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import pannel from "../../components/pannel";
import comeacharts from "../../components/comecharts";
import { api_query } from "../../api/home";

export default {
  components: {
    pannel,
    comeacharts,
  },
  data() {
    return {
      pannel_data: [
        { title: "总订单", ice: "icon-dingdan1", count: 9000, color: "red" },
        {
          title: "总订单",
          ice: "icon-dangrixiaoshoue",
          count: 9000,
          color: "blue",
        },
        { title: "总订单", ice: "icon-dingdan", count: 9000, color: "yellow" },
        {
          title: "总订单",
          ice: "icon-a-icon-xiaoshoue-fuben",
          count: 9000,
          color: "orange",
        },
      ],

      obj: {
        totalOrder: "",
        totalAmount: "",
        todayOrder: "",
        totayAmount: "",
        xData: "",
        orderData: "",
        amountData: "",
      },
      nav: {
        title: "数据统计",
        legend: ["订单", "金额"],
        xAxis: [],
        series: [],
      },
    };
  },
  mounted() {
    this.query();
  },
  methods: {
    async query() {
      let rst = await api_query(this.obj);
      console.log(rst);
      let {
        totalOrder,
        totalAmount,
        todayOrder,
        totayAmount,
        xData,
        orderData,
        amountData,
      } = rst;
      [totalOrder, totalAmount, todayOrder, totayAmount].forEach(
        (item, index) => {
          this.pannel_data[index].count = item;
        }
      );
      this.nav.xAxis = xData;
      this.nav.series = [amountData, orderData].map((item, index) => {
        return {
          name: ["金额", "订单"][index],
          type: "line",
          stack: "Total",
          data: item,
        };
      });
    },
  },
};
</script>

<style lang="less" scoped>
</style>